<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActiveSupport::Cache::Strategy::LocalCache</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/github.css" type="text/css" media="screen" />
<script src="../../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            ActiveSupport::Cache::Strategy::LocalCache 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../../files/activesupport/lib/active_support/cache/strategy/local_cache_rb.html">activesupport/lib/active_support/cache/strategy/local_cache.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  
    <div class="description">
      
<p>Caches that implement <a href="LocalCache.html">LocalCache</a> will be
backed by an in-memory cache for the duration of a block. Repeated calls to
the cache for the same key will hit the in-memory cache for faster access.</p>

    </div>
  


  


  
  


  
    <!-- Namespace -->
    <div class="sectiontitle">Namespace</div>
    <ul>
      
        <li>
          <span class="type">CLASS</span>
          <a href="LocalCache/LocalStore.html">ActiveSupport::Cache::Strategy::LocalCache::LocalStore</a>
        </li>
      
    </ul>
  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>M</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="LocalCache.html#method-i-middleware">middleware</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>W</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="LocalCache.html#method-i-with_local_cache">with_local_cache</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-middleware">
            
              <b>middleware</b>()
            
            <a href="LocalCache.html#method-i-middleware" name="method-i-middleware" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Middleware class can be inserted as a Rack handler to be local cache for
the duration of request.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-middleware_source')" id="l_method-i-middleware_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/fdb3e7341157f618f65683d08e1a55981a5d91d2/activesupport/lib/active_support/cache/strategy/local_cache.rb#L91" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-middleware_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 91</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">middleware</span>
  <span class="ruby-ivar">@middleware</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Middleware</span>.<span class="ruby-identifier">new</span>(
    <span class="ruby-string">&quot;ActiveSupport::Cache::Strategy::LocalCache&quot;</span>,
    <span class="ruby-identifier">local_cache_key</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-with_local_cache">
            
              <b>with_local_cache</b>()
            
            <a href="LocalCache.html#method-i-with_local_cache" name="method-i-with_local_cache" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Use a local cache for the duration of block.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-with_local_cache_source')" id="l_method-i-with_local_cache_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/fdb3e7341157f618f65683d08e1a55981a5d91d2/activesupport/lib/active_support/cache/strategy/local_cache.rb#L60" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-with_local_cache_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 60</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">with_local_cache</span>
  <span class="ruby-identifier">use_temporary_local_cache</span>(<span class="ruby-constant">LocalStore</span>.<span class="ruby-identifier">new</span>) { <span class="ruby-keyword">yield</span> }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    